<template>
  <div id="control">
    <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="rules" ref="ruleForm">

<a-form-model-item label="应报到时间">
  <div>{{ form.reportToTime }}</div>
</a-form-model-item>

<a-form-model-item label="是否选择门诊">
      <a-radio-group v-model="form.department">
        <a-radio value="1">
          是
        </a-radio>
        <a-radio value="2">
          否
        </a-radio>
      </a-radio-group>
</a-form-model-item>

<a-form-model-item label="美沙酮治疗门诊" v-if="form.department == 1">
  <a-select v-model="form.clinicName" placeholder="请选择门诊" >
    <a-select-option v-for="(item) in menzhendata" :key="item.clinicName" :value="item.clinicName" >
      {{ item.clinicName }}
    </a-select-option>
  </a-select>
</a-form-model-item>

<a-form-model-item label="门诊所在地区" v-if="form.department == 1">
  <a-input v-model="form.clinicRegion" :disabled=true 
  :placeholder="get(form.clinicName)" :value="get(form.clinicName)" />
</a-form-model-item>

<a-form-model-item label="上传检测材料" v-if="form.department == 1">
  <j-upload v-model="form.testingMaterials" ></j-upload>
  <span >支持扩展名：.rar .zip .doc .docx .pdf .jpg...</span>
</a-form-model-item>

<a-form-model-item label="签到方式" prop="method">
  <a-select v-model="form.method" placeholder="请选择签到方式" >
    <a-select-option value="1">
      短信签到
    </a-select-option>
    <a-select-option value="2">
      app签到
    </a-select-option>
    <a-select-option value="3">
      小程序签到
    </a-select-option>
  </a-select>
</a-form-model-item>

<a-form-model-item label="签到号码" v-if="form.method == 1" prop="phone">
  <a-input v-model="form.phone" placeholder="请输入签到手机号码"/>
</a-form-model-item>

<a-form-model-item label="人员类型" prop="peopletype">
  <a-select v-model="form.peopletype" placeholder="请选择" >
    <a-select-option value="1">
      社区戒毒人员
    </a-select-option>
    <a-select-option value="2">
      社区康复人员
    </a-select-option>
  </a-select>
</a-form-model-item>

<a-form-model-item label="应按期尿检时间" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>
<a-form-model-item label="应按期尿检次数" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>
<a-form-model-item label="应按期报告时间" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>
<a-form-model-item label="应按期访谈时间" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>
<a-form-model-item label="应按期评估时间" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>
<a-form-model-item label="风险等级评估时间" v-if="form.peopletype">
  <div>{{  }}</div>
</a-form-model-item>





</a-form-model>
  </div>
  
</template>

<script>
import {allClinicInfo} from '@/api/sjsk/reportList'
export default {
  props:['sjskPersonInfoVO','huancun'],
  methods:{
    get(val){
      // console.log((this.menzhendata.filter(item => item.clinicName == val)));
      // this.menzhendata.filter(item => item.clinicName == val)[0]
      this.form.clinicId = this.menzhendata.filter(item => item.clinicName == val)[0]?
      this.menzhendata.filter(item => item.clinicName == val)[0].clinicId:''
      this.form.clinicRegion = this.menzhendata.filter(item => item.clinicName == val)[0]?
      this.menzhendata.filter(item => item.clinicName == val)[0].clinicRegion:''

      return this.form.clinicRegion
    },
   
    ControlForm(val){
      this.$emit('ControlForm',val)
    },
    getmenzen(){
      allClinicInfo().then((res) => {
        if (res.success) {
          this.menzhendata = res.result
          // console.log(this.menzhendata);
          this.loading = false
        } else {
          // this.pageData = {}
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
   }
  },
  data() {
    return {
      labelCol: { span: 3 },
      wrapperCol: { span: 6 },
      form: {
        phone:this.sjskPersonInfoVO.phone,
        reportToTime:this.sjskPersonInfoVO.reportToTime,
      },
      menzhendata:[],
      rules:{
        method: [{ required: true, message: '请选择签到方式', trigger: 'change' },],
        phone: [{ required: true, message: '请选择签到号码', trigger: 'change' },],
        peopletype: [{ required: true, message: '请选择人员类型', trigger: 'change' },],

        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
        // peopletype: [{ required: true, message: '请下载文件', trigger: 'change' },],
      }
    };
  },
  watch:{
    form:{
      immediate:true,
      deep:true,
      handler(val){
        let {testingMaterials,clinicRegion,clinicName,clinicId} = val
        // this.ControlForm({
        //   testingMaterials:testingMaterials,
        //   clinicRegion:clinicRegion,
        //   clinicName:clinicName,
        //   clinicId:clinicId
        // })
        this.ControlForm(val)
      }
    },
    huancun:{
      immediate:true,
      deep:true,
      handler(val){
        if(val.mstDTO){
          this.form = val.mstDTO
        }
      }
    }
  },
  mounted () {
    this.getmenzen()
  }
};
</script>

<style lang="less" scoped>
#control{
  margin-top:50px
}
</style>